/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package clases;
import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;

/**
 *
 * @author Administrador
 */
public class VerSoloTxt extends FileView {
   File txt = new File("txt");
    
    public String getName(File f) {
        
        return null; // let the L&F FileView figure this out
    }
    
    public String getDescription(File f) {
        return null; // let the L&F FileView figure this out
    }
    
    public Boolean isTraversable(File f) {
        return null; // let the L&F FileView figure this out
    }
    
    public String getTypeDescription(File f) {
        String extension = getExtension(f);
        String type = null;

        if (extension != null) {
            if (extension.equals("txt") ||
                extension.equals("TXT")) {
                type = "txt File";
            
            } 
        }
        return type;
    }
    
    public File getArchivo(File f) {
        String extension = getExtension(f);
        File archivo = null;
        if (extension != null) {
            if (extension.equals("txt") ||
                extension.equals("TXT")) {
                archivo = txt;
            
            }  
        }
        return archivo;
    }
    
    // Get the extension of this file. Code is factored out
    // because we use this in both getIcon and getTypeDescription
    private String getExtension(File f) {

        String ext = null;
        String s = f.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }
}